<page-header model="ctrl.navModel"></page-header>

<div class="page-container page-body">
  <h3 class="page-sub-heading">用户资料</h3>

	<form name="ctrl.userForm" class="gf-form-group">

		<div class="gf-form max-width-30">
			<span class="gf-form-label width-8">姓名</span>
			<input class="gf-form-input max-width-22" type="text" required ng-model="ctrl.user.name" >
		</div>
		<div class="gf-form max-width-30">
			<span class="gf-form-label width-8">Email</span>
			<input class="gf-form-input max-width-22" type="email" ng-readonly="ctrl.readonlyLoginFields" required ng-model="ctrl.user.email">
      <i ng-if="ctrl.readonlyLoginFields" class="fa fa-lock gf-form-icon--right-absolute" bs-tooltip="'登录详情已被锁定 — 被另一系统管理。'"></i>
    </div>
		<div class="gf-form max-width-30">
			<span class="gf-form-label width-8">用户名</span>
      <input class="gf-form-input max-width-22" type="text" ng-readonly="ctrl.readonlyLoginFields" required ng-model="ctrl.user.login">
      <i ng-if="ctrl.readonlyLoginFields" class="fa fa-lock gf-form-icon--right-absolute" bs-tooltip="'登录详情已被锁定 — 被另一系统管理。'"></i>
    </div>
		<div class="gf-form-button-row">
			<button type="submit" class="btn btn-success" ng-click="ctrl.update()">保存</button>
		</div>
	</form>

	<prefs-control mode="user"></prefs-control>

	<h3 class="page-heading" ng-show="ctrl.showOrgsList">组织</h3>
  <div class="gf-form-group" ng-show="ctrl.showOrgsList">
		<table class="filter-table form-inline">
			<thead>
				<tr>
					<th>名称</th>
					<th>角色</th>
					<th></th>
				</tr>
			</thead>
			<tbody>
				<tr ng-repeat="org in ctrl.orgs">
					<td>{{org.name}}</td>
					<td>{{org.role}}</td>
					<td class="text-right">
						<span class="btn btn-primary btn-mini" ng-show="org.orgId === contextSrv.user.orgId">
							当前
						</span>
						<a ng-click="ctrl.setUsingOrg(org)" class="btn btn-inverse btn-mini" ng-show="org.orgId !== contextSrv.user.orgId">
              选择
						</a>
					</td>
				</tr>
			</tbody>
		</table>
	</div>

